//
//  Datapicker.m
//  ZZmetro
//
//  Created by 一介布衣 on 2020/6/17.
//  Copyright © 2020 一介布衣. All rights reserved.
//

#import "Datapicker.h"
#import "LYSDatePickerController.h"
#import "SingleColumnDataPickerView.h"
#import "BottomSheet.h"

@interface Datapicker() <LYSDatePickerSelectDelegate>

@end

@implementation Datapicker
/**
 * 年月日时分秒
 */
+(void) pickYearMonthDayHourMinute:(UIViewController *) contrller {
    LYSDatePickerController *datePicker = [[LYSDatePickerController alloc] init];
    datePicker.headerView.backgroundColor = [UIColor whiteColor];
    datePicker.indicatorHeight = 1;
    //datePicker.delegate = self;
    datePicker.headerView.centerItem.textColor = [UIColor darkGrayColor];
    datePicker.headerView.leftItem.textColor = [UIColor grayColor];
    datePicker.headerView.rightItem.textColor = [UIColor blackColor];
    datePicker.pickHeaderHeight = 50;
    datePicker.pickType = LYSDatePickerTypeDayAndTime;
    datePicker.minuteLoop = YES;
    datePicker.headerView.showTimeLabel = NO;
    datePicker.weakDayType = LYSDatePickerWeakDayTypeUSShort;
    datePicker.showWeakDay = YES;
    [datePicker setDidSelectDatePicker:^(NSDate *date) {
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"yyyy/MM/dd/HH/mm"];
        NSString *currentDate = [dateFormat stringFromDate:date];
        [Toast toast:currentDate];
    }];
    [datePicker showDatePickerWithController:contrller];
}

/**
 * 年月日
 */
+(void) pickYearMonthDay:(UIViewController *) contrller {
    LYSDatePickerController *datePicker = [[LYSDatePickerController alloc] init];
    datePicker.headerView.backgroundColor = [UIColor whiteColor];
    datePicker.indicatorHeight = 1;
    //datePicker.delegate = self;
    datePicker.headerView.centerItem.textColor = [UIColor darkGrayColor];
    datePicker.headerView.leftItem.textColor = [UIColor grayColor];
    datePicker.headerView.rightItem.textColor = [UIColor blackColor];
    datePicker.pickHeaderHeight = 50;
    datePicker.pickType = LYSDatePickerTypeDay;
    datePicker.minuteLoop = YES;
    datePicker.headerView.showTimeLabel = NO;
    datePicker.weakDayType = LYSDatePickerWeakDayTypeCNShort;
    datePicker.showWeakDay = YES;
    [datePicker setDidSelectDatePicker:^(NSDate *date) {
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"yyyy/MM/dd/HH/mm"];
        NSString *currentDate = [dateFormat stringFromDate:date];
        [Toast toast:currentDate];
    }];
    [datePicker showDatePickerWithController:contrller];

}

/**
 * 年月日
 */
+(void) pickHourMinute:(UIViewController *) contrller {
    LYSDatePickerController *datePicker = [[LYSDatePickerController alloc] init];
    datePicker.headerView.backgroundColor = UIColor.whiteColor;
    datePicker.indicatorHeight = 1;
    //datePicker.delegate = self;
    datePicker.headerView.centerItem.textColor = [UIColor darkGrayColor];
    datePicker.headerView.leftItem.textColor = [UIColor grayColor];
    datePicker.headerView.rightItem.textColor = [UIColor blackColor];
    datePicker.pickHeaderHeight = 50;
    datePicker.pickType = LYSDatePickerTypeTime;
    datePicker.minuteLoop = YES;
    datePicker.headerView.showTimeLabel = NO;
    datePicker.weakDayType = LYSDatePickerWeakDayTypeUSDefault;
    datePicker.showWeakDay = YES;
    [datePicker setDidSelectDatePicker:^(NSDate *date) {
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"yyyy/MM/dd/HH/mm"];
        NSString *currentDate = [dateFormat stringFromDate:date];
        [Toast toast:currentDate];
    }];
    [datePicker showDatePickerWithController:contrller];
}

+(void) pickData:(UIViewController *) contrller srcData:(NSArray *) srcData callback:(DataPickerSelectedBlock) block {
    SingleColumnDataPickerView *pickView = [[SingleColumnDataPickerView alloc]init];
    [pickView setPickData:srcData];
   
    BottomSheet *bottomSheet = [[BottomSheet alloc] init];
    [bottomSheet setBootSheetContentView:pickView];
    [bottomSheet show:contrller confirm:^{
        [Toast toast:@"点击了确定"];
        [Toast toast:pickView.pickedData];
    } cancel:^{
        [Toast toast:@"点击了取消"];
    }];
}

@end
